<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>

<script>
// 示例 1: 作用域
function exampleLet() {
  let a = 10;
  if (true) {
    let b = 20; // b 只在这个 if 语句块内有效
    console.log(a); // 输出 10
  }
  console.log(a); // 输出 10
  // console.log(b); // 报错 ReferenceError: b is not defined
}

exampleLet();

// 示例 2: 提升
console.log(x); // 报错 ReferenceError: Cannot access 'x' before initialization
let x = 5;
</script>
</html>